package com.hzit.auth.handler;

import com.hzit.common.util.R;
import com.hzit.common.util.ResponseUtil;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 类名：
 * 作者：WF
 * 功能：授权失败处理器
 */
@Component
public class HzitAccessDeniedHandler implements AccessDeniedHandler {
	@Override
	public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException {
		R<Object> fail = R.fail(HttpStatus.FORBIDDEN.value(), "无权访问！");
		ResponseUtil.out(response,fail);
	}
}
